package com.ht.module.info.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.util.StringUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.util.CollectionUtils;
import com.ht.module.info.service.IInfoOrderDetailsService;
import com.ht.util.*;
import com.ht.module.info.entity.InfoOrderDetails;

import javax.validation.Valid;
import java.util.*;


/**
 * <p>
 * 订单详情表 前端控制器
 * </p>
 *
 * @author Auto-generator
 * @since 2021-12-03
 */
@Api(tags = "订单详情表 ")
@RestController
@RequestMapping("/info-order-details")
public class InfoOrderDetailsController {

    
    @Autowired
    private IInfoOrderDetailsService iInfoOrderDetailsService;


    /**
     * 修改状态
     * @return
     */
    @PostMapping("/updateState/{id}/{val}")
    public JsonResult updateState(@PathVariable String id, @PathVariable String val){
        iInfoOrderDetailsService.updateState(id,val);
        return JsonResult.success();
    }


    /**
    * 分页查询
    */
    @ApiOperation(value = "分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<InfoOrderDetails> pager, InfoOrderDetails infoOrderDetails){
        return JsonResult.success(iInfoOrderDetailsService.page(pager));
    }

    @GetMapping("/findByOrderId/{id}")
    @ApiOperation(value = "通过订单id查询")
    public JsonResult findByOrderId(@PathVariable(value = "id") String id){
        return JsonResult.success(iInfoOrderDetailsService.findByOrderId(id));
    }


    @GetMapping("/findByOrderIdAndMerchants/{id}")
    @ApiOperation(value = "通过订单id和商户查询")
    public JsonResult findByOrderIdAndMerchants(@PathVariable(value = "id") String id){
        return JsonResult.success(iInfoOrderDetailsService.findByOrderIdAndMerchants(id));
    }




}
